home *** CD-ROM | disk | FTP | other *** search
/ MaxiMac 2000 December / MaxiMac 109.iso / Macworld on CD n°109 / Applications (Mac OS X PB) / MacOSX ScreenSavers / Source Code / Sproingees / sproingiewrap.c < prev   
Encoding:
C/C++ Source or Header  |  2000-08-17  |  4.1 KB  |  151 lines  |  [????/????]

  1. /* -*- Mode: C; tab-width: 4 -*- */
  2. /* sproingiewrap.c - sproingies wrapper */
  3.  
  4. /*-
  5.  * sproingiewrap.c - Copyright 1996 Sproingie Technologies Incorporated.
  6.  *
  7.  * Permission to use, copy, modify, and distribute this software and its
  8.  * documentation for any purpose and without fee is hereby granted,
  9.  * provided that the above copyright notice appear in all copies and that
  10.  * both that copyright notice and this permission notice appear in
  11.  * supporting documentation.
  12.  *
  13.  * This file is provided AS IS with no warranties of any kind.  The author
  14.  * shall have no liability with respect to the infringement of copyrights,
  15.  * trade secrets or any patents by this file or any part thereof.  In no
  16.  * event will the author be liable for any lost revenue or profits or
  17.  * other special, indirect and consequential damages.
  18.  *
  19.  *    Programming:  Ed Mackey, http://www.netaxs.com/~emackey/
  20.  *    Sproingie 3D objects modeled by:  Al Mackey, al@iam.com
  21.  *       (using MetaNURBS in NewTek's Lightwave 3D v5).
  22.  *
  23.  * Revision History:
  24.  * 26-Apr-97: Added glPointSize() calls around explosions, plus other fixes.
  25.  * 28-Mar-97: Added size support.
  26.  * 22-Mar-97: Updated to use glX interface instead of xmesa one.
  27.  *              Also, support for multiscreens added.
  28.  * 20-Mar-97: Updated for xlockmore v4.02alpha7 and higher, using
  29.  *              xlockmore's built-in Mesa/OpenGL support instead of
  30.  *              my own.  Submitted for inclusion in xlockmore.
  31.  * 09-Dec-96: Written.
  32.  */
  33.  
  34. /*-
  35.  * The sproingies have six "real" frames, (s1_1 to s1_6) that show a
  36.  * sproingie jumping off a block, headed down and to the right.  But
  37.  * the program thinks of sproingies as having twelve "virtual" frames,
  38.  * with the latter six being copies of the first, only lowered and
  39.  * rotated by 90 degrees (jumping to the left).  So after going
  40.  * through 12 frames, a sproingie has gone down two rows but not
  41.  * moved horizontally. 
  42.  *
  43.  * To have the sproingies randomly choose left/right jumps at each
  44.  * block, the program should go back to thinking of only 6 frames,
  45.  * and jumping down only one row when it is done.  Then it can pick a
  46.  * direction for the next row.
  47.  *
  48.  * (Falling off the end might not be so bad either.  :) )  
  49.  */
  50.  
  51. # define PROGCLASS                    "Sproingies"
  52. # define HACK_INIT                    init_sproingies
  53. # define HACK_DRAW                    draw_sproingies
  54. # define sproingies_opts            xlockmore_opts
  55. # define DEFAULTS    "*delay:        100     \n"            \
  56.                     "*count:        5       \n"            \
  57.                     "*cycles:        0       \n"            \
  58.                     "*size:            0       \n"            \
  59.                     "*wireframe:    False    \n"
  60. /*
  61. ModeSpecOpt sproingies_opts =
  62. {0, NULL, 0, NULL, NULL};
  63.  
  64. #ifdef USE_MODULES
  65. ModStruct   sproingies_description =
  66. {"sproingies", "init_sproingies", "draw_sproingies", "release_sproingies",
  67.  "refresh_sproingies", "init_sproingies", NULL, &sproingies_opts,
  68.  1000, 5, 0, 400, 4, 1.0, "",
  69.  "Shows Sproingies!  Nontoxic.  Safe for pets and small children", 0, NULL};
  70.  
  71. #endif
  72. */
  73. #define MINSIZE 32
  74.  
  75. #include <OpenGL/glu.h>
  76. #include <time.h>
  77.  
  78.     GLuint count = 5;
  79. //int mono_sp = 0;
  80. extern int mono_sp;
  81.     int wfmode = 0;
  82.     int screen = 1;
  83.  
  84.     int cycles = 0;
  85.  
  86. void
  87. SproingieSwap(void)
  88. {
  89.     glFinish();
  90. }
  91.  
  92.  
  93. void
  94. init_sproingies()
  95. {
  96.  
  97.         int grnd = 0;
  98.         int mspr = 0;
  99.  
  100.         grnd = (cycles >> 1);
  101.         if (grnd > 2)
  102.             grnd = 2;
  103.  
  104.         mspr = count;
  105.         if (mspr > 100)
  106.             mspr = 100;
  107.  
  108.         /* wireframe, ground, maxsproingies */
  109.         InitSproingies(wfmode, grnd, mspr, 1, 1, mono_sp);
  110.  
  111.         DisplaySproingies();
  112.  
  113. }
  114.  
  115. void reshape_sproingies( int width, int height )
  116. {
  117.     printf("width = %f, height = %f\n", width, height);
  118.     glViewport(0, 0, width, height);
  119.       glMatrixMode(GL_PROJECTION);
  120.       glLoadIdentity();
  121.       gluPerspective(65.0, (GLfloat) width / (GLfloat) height, 0.1, 2000.0);    /* was 200000.0 */
  122.       glMatrixMode(GL_MODELVIEW);
  123. }
  124.  
  125. /* ARGSUSED */
  126. void
  127. draw_sproingies()
  128. {
  129.  
  130.     glDrawBuffer(GL_BACK);
  131.     NextSproingieDisplay();    /* It will swap. */
  132. }
  133.  
  134. void
  135. refresh_sproingies()
  136. {
  137.     /* No need to do anything here... The whole screen is updated
  138.      * every frame anyway.  Otherwise this would be just like
  139.      * draw_sproingies, above, but replace NextSproingieDisplay(...)
  140.      * with DisplaySproingies(...).
  141.      */
  142. }
  143.  
  144. void
  145. release_sproingies()
  146. {
  147.       CleanupSproingies();
  148. }
  149.  
  150. /* End of sproingiewrap.c */
  151.